package farmer.gui;

import java.awt.Graphics2D;
import java.awt.geom.RoundRectangle2D;

import core.gui.Button;

public class MainMenuButton extends Button{
	
	private MainMenuGUI gui;
	private int type;

	public MainMenuButton(String name, MainMenuGUI gui, int type) {
		super(name);
		this.gui = gui;
		this.type = type;
		boundingRect = new RoundRectangle2D.Float(0, 0, 10, 10, 10, 10);
	}
	
	@Override
	public void drawButton(Graphics2D g){
		super.drawButton(g);
		int x = (int) boundingRect.getCenterX();
		int y = (int) boundingRect.getCenterY();
		int w = g.getFontMetrics().charsWidth(name.toCharArray(), 0, name.length());
		int h = g.getFontMetrics().getHeight();
		g.drawString("_", x-w/2, y+h/4);
	}
	
	@Override
	public void isClicked(){
		if(type == MainMenuGUI.IDTutorial){
			gui.followTutorial();
		}else if(type == MainMenuGUI.IDStartGame){
			gui.startGame();
		}
	}

}
